package com.hongmeng.teamwork.convert;

import com.hongmeng.teamwork.entity.dto.ProjectGroupRelDto;
import com.hongmeng.teamwork.entity.dto.TeamworkProjectDto;
import com.hongmeng.teamwork.entity.po.TeamworkProject;
import com.hongmeng.teamwork.entity.po.User;
import com.hongmeng.teamwork.entity.vo.TeamworkProjectVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface TeamworkProjectConvert {

    TeamworkProjectConvert INSTANCE = Mappers.getMapper(TeamworkProjectConvert.class);

    TeamworkProject convertDtoToEntity(TeamworkProjectDto teamworkProjectDto);

    List<TeamworkProjectVo> convertEntityToVoList(List<TeamworkProject> projectList);

    @Mappings({
            @Mapping(target = "projectId", source = "project.id"),
            @Mapping(target = "name", source = "project.name"),
            @Mapping(target = "openId", source = "project.openId"),
            @Mapping(target = "createdUser", ignore = true)
    })
    ProjectGroupRelDto convertEntityToRelDto(TeamworkProject project, TeamworkProjectDto teamworkProjectDto);
}
